﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bovril.Rodney.Core
{
    internal static class BetfairAPIGlobalRequestFactory
    {
        internal static BFGlobalServiceReference.GetEventsReq CreateGetEventsRequest(String sessionToken, int eventParentId)
        {
            BFGlobalServiceReference.GetEventsReq getEventsRequest = new BFGlobalServiceReference.GetEventsReq();
            getEventsRequest.header = CreateGlobalRequestHeader(sessionToken);
            getEventsRequest.eventParentId = eventParentId;

            return getEventsRequest;
        }

        internal static BFGlobalServiceReference.GetEventTypesReq CreateGetEventTypesRequest(String sessionToken)
        {
            BFGlobalServiceReference.GetEventTypesReq getEventTypesRequest = new BFGlobalServiceReference.GetEventTypesReq();
            getEventTypesRequest.header = CreateGlobalRequestHeader(sessionToken);

            return getEventTypesRequest;
        }

        internal static BFGlobalServiceReference.LoginReq CreateLoginRequest(String username, String password)
        {
            BFGlobalServiceReference.LoginReq loginRequest = new BFGlobalServiceReference.LoginReq();
            loginRequest.username = username;
            loginRequest.password = password;
            loginRequest.productId = defaultProductId_;

            return loginRequest;
        }

        internal static BFGlobalServiceReference.LogoutReq CreateLogoutRequest(String sessionToken)
        {
            BFGlobalServiceReference.LogoutReq logoutRequest = new BFGlobalServiceReference.LogoutReq();
            logoutRequest.header = CreateGlobalRequestHeader(sessionToken);

            return logoutRequest;
        }

        private static BFGlobalServiceReference.APIRequestHeader CreateGlobalRequestHeader(String sessionToken)
        {
            var header = new BFGlobalServiceReference.APIRequestHeader();
            header.sessionToken = sessionToken;

            return header;
        }

        private static readonly int defaultProductId_ = 82;
    }
}
